use anyhow::{Context, Result};
use std::fs;
use std::path::Path;

const LONG_QUESTION_FILE: &str = "long_question.md";
pub fn load_long_question(working_path: &Path) -> Result<String> {
    let file_path = &working_path.join(LONG_QUESTION_FILE);

    fs::read_to_string(file_path).context(format!("请将你的提问输入到{:?}文件中", file_path))
}

pub fn write_long_question(working_path: &Path, content: Option<&String>) -> Result<()> {
    let file_path = &working_path.join(LONG_QUESTION_FILE);
    if let Some(content) = content {
        fs::write(file_path, content).context(format!("无法写入到{:?}文件中", file_path))?;
    }
    Ok(())
}
